from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from .index import index_bp
from .download import download_bp
from .database import db_connect
from flask_cors import CORS


def create_app():
    app = Flask(__name__)

    CORS(app, supports_credentials=True)    # 允许同一服务器上的5173端口(vue3)跨源访问服务器资源
    app.secret_key = 'my_secret_key'  # 用于注册功能的session



    db_connect(app)

    app.register_blueprint(index_bp)
    app.register_blueprint(download_bp)

    return app
